package com.gree.setup.email;

import com.gree.email.scm.EmailMsgConsumer;
import com.threadnew.tnmq.consumer.RocketMQConsumer;
import com.threadnew.tnmq.factory.MQFactory;
import org.apache.rocketmq.client.exception.MQClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName EmailConsumerConfiguration
 * @Description TODO  邮件消费者配置中心
 * @Author ThreadNew
 * @Date 2021/5/20 13:47
 * Version 1.0
 **/
@Configuration
public class EmailConsumerConfiguration {
    //
    @Autowired
    private EmailMsgConsumer emailMsgConsumer;

    @Bean(name = "ScmEmailConsumer", initMethod = "start", destroyMethod = "shutdown")
    public RocketMQConsumer createScmEmailConsumer() throws MQClientException {
        RocketMQConsumer consumer = MQFactory.createConsumer("10.2.30.75:9000", "RC_SCM_EMAIL_CGROUP", "RC_SCM_EMAIL_TOPIC", "*");
        consumer.registerConsumerMessageListener(emailMsgConsumer);
        return consumer;
    }
}
